<?php
/**
 *@作者:MissZhang
 *@邮箱:<787727147@qq.com>
 *@创建时间:2022/10/12 11:23
 *@说明:自提点模型
 */
namespace app\common\model;
use think\Model;

class Pick extends Model
{
    protected $pk = "id";
    // 定义时间戳字段名
    protected $createTime = 'add_time';
    //修改format类型
    protected $dateFormat = "Y-m-d H:i:s";
    protected $type=[
        'profits_bili'        =>  'float',
        'rebate_bili'         =>  'float',
    ];
    public function getPkAttr() {
        return $this->pk;
    }
    public function user(){
        return $this->hasOne(Users::class, 'user_id','user_id');
    }
    public function getStoreLogoAttr($value) {
        if (strpos($value, 'http') === false){
            return SITE_URL.$value;
        }
        return $value;
    }
    public function getCheckTimeTextAttr($value) {
        if ($value){
            return date($this->dateFormat,$value);
        }
        return "--";
    }
    public function getRefuseTimeTextAttr($value) {
        if ($value){
            return date($this->dateFormat,$value);
        }
        return "--";
    }
    public function getStatusTextAttr($value,$data) {
        $types = [-1=>'待审核',1=>'已开通',2=>'审核失败',3=>'已关闭'];
        return $types[$data['status']];
    }
    public function getAllAddressAttr($value,$data) {
        return $data['province'].$data['city'].$data['district'].$data['store_address'];
    }
}
